<?php
ob_start();
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL | E_NOTICE);
include ("config.inc.php");
include ("jsonEncode.php");

// username and password sent from form
$username = '';
$password = '';
$username = mysql_real_escape_string($_GET['username']);
$password = mysql_real_escape_string($_GET['password']);

$sql    = "SELECT c_id FROM clients WHERE username='$username' AND password='$password' LIMIT 1";
$result = mysql_query($sql);

$data   = mysql_fetch_array($result);
$count  = mysql_num_rows($result);

if($count==1){
	$_SESSION['username']  = $username;
	$_SESSION['password']  = $password;
	$_SESSION['client_id'] = $data['c_id'];
	$_SESSION['loggedin']  = "1234";
	// valid
	$var = array('valid' => 1, 'username' => $username, 'password' => $password);
	print php_json_encode($var);
}else{
	// invalid
	$var = array('valid' => 0, 'username' => $username, 'password' => $password);
	print php_json_encode($var);
}
?>


